Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reply to Web API run with result #2108

Merged
merged 11 commits into from
Aug 15, 2024
Merged

Reply to Web API run with result #2108

merged 11 commits into from
Aug 15, 2024

Conversation

xsebek
Copy link
Member

@xsebek xsebek commented Aug 11, 2024

This uses the "IO wrapper" trick from #2098 - thus we can be sure that TUI will be the producer and Web API the consumer.

Example:

cabal run swarm -O0 -- --scenario blank  # in another terminal
curl -XGET --header "Content-Type: text/plain;charset=utf-8" localhost:5357/code/run --data "1 + 1"
{"InProgress":[]}
{"Complete":"it1 : Int = 2"}

You can also test it with the shell script, that tries to act as a REPL and strips the JSON unless it gets an error:

❯ scripts/remote-repl.sh
> move
> scan down
it0 : Unit + Text = inl ()
> grab // exception written to log is not shown here
> grob
{
  "ParseError": "1:1: Unbound variable grob\n"
}
>

* send InProgress or Rejected
* once REPLDone send Complete
* closes #1426
@xsebek xsebek requested review from kostmo and byorgey August 11, 2024 16:53
xsebek and others added 4 commits August 11, 2024 18:54
* add script to work as a minimal REPL, that can be run from different window or machine
Copy link
Member

@kostmo kostmo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works for me! Very cool.

For the test procedure, should specify that one must run a "creative" game to obtain the expected output.

The servant "streaming" API is new to me. Perhaps add a comment to introduce readers to how it is being used here.

Copy link
Member

@byorgey byorgey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Neat!

restyled-io bot and others added 2 commits August 15, 2024 00:07
Co-authored-by: Restyled.io <commits@restyled.io>
@xsebek
Copy link
Member Author

xsebek commented Aug 14, 2024

@kostmo @byorgey I added a big note that tries to explain this streaming thing. I don't have any prior experience with streaming, so please take it with a grain of salt.

It might even be overkill here, but I wanted to show that the program was parsed and the base is running it:
Screenshot 2024-08-15 at 12 34 13 AM

I think this approach would really pay off when streaming logs. 🤔

@xsebek xsebek added the merge me Trigger the merge process of the Pull request. label Aug 15, 2024
@mergify mergify bot merged commit 1994ab2 into main Aug 15, 2024
12 checks passed
@mergify mergify bot deleted the task/xsebek/web-repl-reply branch August 15, 2024 17:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merge me Trigger the merge process of the Pull request.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Return real result in Web API /code/run
3 participants